package com.qing.seckill.controller;


import com.qing.seckill.entity.TbSeckillOrder;
import com.qing.seckill.service.ITbSeckillOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhipeng.cao
 * @since 2021-04-19
 */
@RestController
@RequestMapping("/order")
public class TbSeckillOrderController {

	@Autowired
	private ITbSeckillOrderService tbSeckillOrderService;

	@RequestMapping("/saveOrder/{id}")
	public ModelAndView serveOrder(@PathVariable("id") Long id, ModelAndView modelAndView) {
		modelAndView.setViewName("result");
		modelAndView.addObject("info", tbSeckillOrderService.serveOrder(id));
		return modelAndView;
	}


	@RequestMapping("/saveOrder2/{id}")
	public ModelAndView serveOrder2(@PathVariable("id") Long id, ModelAndView modelAndView) {
		modelAndView.setViewName("result");
		modelAndView.addObject("info", tbSeckillOrderService.serveOrder(id, "zhipeng.cao"));
		return modelAndView;
	}


}
